package jmine.tec.rpc.integration.server;

import java.beans.PropertyDescriptor;

import jmine.tec.rpc.integration.api.rs.AssociatedMockEntityRS;
import jmine.tec.rpc.integration.domain.AssociatedMockEntity;
import jmine.tec.rpc.server.representation.RepresentationContext;
import jmine.tec.rpc.server.representation.representers.reflection.PropertyRepresenter;

import org.apache.commons.beanutils.PropertyUtils;

/**
 * Representer específico para a propriedade "custom" de um AssociatedMockEntityRS
 * 
 * @author lundberg
 */
public class AssociatedMockEntityCustomPropertyRepresenter implements PropertyRepresenter<AssociatedMockEntityRS, AssociatedMockEntity> {

    /**
     * {@inheritDoc}
     */
    public boolean isApplicableTo(PropertyDescriptor representationProperty) {
        return true;
    }

    /**
     * {@inheritDoc}
     */
    public void representProperty(RepresentationContext context, AssociatedMockEntityRS representation,
            PropertyDescriptor representationProperty, AssociatedMockEntity object) throws Exception {
        PropertyUtils.setProperty(representation, representationProperty.getName(), object.getClass().getName());
    }
}
